﻿class Line {
	private var __fromPT:Object;
	private var __toPT:Object;
	private var __x:Number;
	private var __y:Number;
	private var __len:Number;
	private var __angle:Number;
	function Line(fromPT:Object, toPT:Object) {
		__fromPT = fromPT;
		__toPT = toPT;
		count();
	}
	private function count():Void {
		__x = __fromPT.x;
		__y = __fromPT.y;
		__len = Math.sqrt(Math.pow(__toPT.x-__fromPT.x, 2)+Math.pow(__toPT.y-__fromPT.y, 2));
		__angle = Math.atan2(__toPT.y-__fromPT.y, __toPT.x-__fromPT.x);
	}
	public function get x():Number {
		return __x;
	}
	public function get y():Number {
		return __y;
	}
	public function get len():Number {
		return __len;
	}
	public function get angle():Number {
		return __angle;
	}
	public function getReverseLine():Line {
		return new Line(__toPT, __fromPT);
	}
	public function getBounds():Object {
		var aryX:Array = [__fromPT.x, __toPT.x];
		aryX.sort(Array.NUMERIC);
		var aryY:Array = [__fromPT.y, __toPT.y];
		aryY.sort(Array.NUMERIC);
		return {xMin:aryX[0], xMax:aryX[1], yMin:aryY[0], yMax:aryY[1]};
	}
}
